diff options
| author | Armand Philippot <git@armandphilippot.com> | 2022-01-29 19:03:59 +0100 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2022-01-29 19:03:59 +0100 |
| commit | 8fb5e4ef3ae925ebc6622711fb5c8c6147642cbc (patch) | |
| tree | 9e99137a7b64ea7993a8311a7162336a551be8b2 /src/pages/thematique/[slug].tsx | |
| parent | 2bae7c43764df5678fe2fc2e68be11ae95d85a41 (diff) | |
| parent | e4d5b8151802517b2943756fc0d09ffa95e2c4e2 (diff) | |
feat(i18n): replace linguijs with formatjs
Diffstat (limited to 'src/pages/thematique/[slug].tsx')
| -rw-r--r-- | src/pages/thematique/[slug].tsx | 46 |
1 files changed, 30 insertions, 16 deletions
diff --git a/src/pages/thematique/[slug].tsx b/src/pages/thematique/[slug].tsx index 9955089..61019fd 100644 --- a/src/pages/thematique/[slug].tsx +++ b/src/pages/thematique/[slug].tsx @@ -1,27 +1,28 @@ import { getLayout } from '@components/Layouts/Layout'; +import PostHeader from '@components/PostHeader/PostHeader'; import PostPreview from '@components/PostPreview/PostPreview'; -import { t } from '@lingui/macro'; -import { NextPageWithLayout } from '@ts/types/app'; -import { TopicPreview, ThematicProps } from '@ts/types/taxonomies'; -import { defaultLocale, loadTranslation } from '@utils/helpers/i18n'; -import { GetStaticPaths, GetStaticProps, GetStaticPropsContext } from 'next'; -import { ParsedUrlQuery } from 'querystring'; -import styles from '@styles/pages/Page.module.scss'; +import Sidebar from '@components/Sidebar/Sidebar'; +import { RelatedTopics, ThematicsList, ToC } from '@components/Widgets'; +import { config } from '@config/website'; import { getAllThematicsSlug, getThematicBySlug, } from '@services/graphql/queries'; -import PostHeader from '@components/PostHeader/PostHeader'; -import { RelatedTopics, ThematicsList, ToC } from '@components/Widgets'; -import { useRef } from 'react'; +import styles from '@styles/pages/Page.module.scss'; +import { NextPageWithLayout } from '@ts/types/app'; import { ArticleMeta } from '@ts/types/articles'; +import { TopicPreview, ThematicProps } from '@ts/types/taxonomies'; +import { loadTranslation } from '@utils/helpers/i18n'; +import { GetStaticPaths, GetStaticProps, GetStaticPropsContext } from 'next'; import Head from 'next/head'; -import Sidebar from '@components/Sidebar/Sidebar'; -import { Article, Graph, WebPage } from 'schema-dts'; -import { config } from '@config/website'; import { useRouter } from 'next/router'; +import { ParsedUrlQuery } from 'querystring'; +import { useRef } from 'react'; +import { useIntl } from 'react-intl'; +import { Article, Graph, WebPage } from 'schema-dts'; const Thematic: NextPageWithLayout<ThematicProps> = ({ thematic }) => { + const intl = useIntl(); const relatedTopics = useRef<TopicPreview[]>([]); const router = useRouter(); @@ -118,14 +119,27 @@ const Thematic: NextPageWithLayout<ThematicProps> = ({ thematic }) => { <div dangerouslySetInnerHTML={{ __html: thematic.content }}></div> {thematic.posts.length > 0 && ( <section className={styles.section}> - <h2>{t`All posts in ${thematic.title}`}</h2> + <h2> + {intl.formatMessage( + { + defaultMessage: 'All posts in {name}', + description: 'ThematicPage: posts list title', + }, + { name: thematic.title } + )} + </h2> <ol className={styles.list}>{getPostsList()}</ol> </section> )} </div> <Sidebar position="right"> <RelatedTopics topics={relatedTopics.current} /> - <ThematicsList title={t`Other thematics`} /> + <ThematicsList + title={intl.formatMessage({ + defaultMessage: 'Others thematics', + description: 'ThematicPage: thematics list widget title', + })} + /> </Sidebar> </article> </> @@ -142,7 +156,7 @@ export const getStaticProps: GetStaticProps = async ( context: GetStaticPropsContext ) => { const { locale } = context; - const translation = await loadTranslation(locale || defaultLocale); + const translation = await loadTranslation(locale); const { slug } = context.params as PostParams; const thematic = await getThematicBySlug(slug); const breadcrumbTitle = thematic.title; |
